package com.gaokao.demo.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gaokao.demo.entity.Onescoreonefile;
import com.gaokao.demo.entity.ProfessionalScore;
import com.gaokao.demo.mapper.OnescoreonefileMapper;
import com.gaokao.demo.service.IOnescoreonefileService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author szs
 */
@Service
public class OnescoreonefileServiceImpl extends ServiceImpl<OnescoreonefileMapper, Onescoreonefile> implements IOnescoreonefileService {

    @Autowired
    private OnescoreonefileMapper onescoreonefileMapper;

    /**
     * 获得指定年份的信息(位次相同)
     *
     * @param map stuAddress、stuLeibie、dates、stuScores、year（指定年份）
     * @return
     */
    @Override
    public Onescoreonefile getPastScore(Map map) {
        List<Onescoreonefile> list = onescoreonefileMapper.getPastList(map);
        for (Onescoreonefile onescoreonefile : list) {
            String stuScores = onescoreonefile.getStuScores();
            if (stuScores != null && stuScores != "" && stuScores.indexOf("-") == -1) {
                return onescoreonefile;
            }
        }
        return null;
    }

    @Override
    public List<ProfessionalScore> getSchool(Map map) {
        return onescoreonefileMapper.getSchool(map);
    }
}
